﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Forums.SyncService;
using Microsoft.Forums.OfflineStore;
using Microsoft.Forums.ForumsProvider;

namespace Microsoft.Forums.Tests.HelperTools.Stubs
{

    /// <summary>
    /// Stub standin for a forum  provider
    /// This lets a test case set what values it expects methods in this class to return
    /// </summary>
    public class ForumsProviderStub : IForumServiceProvider
    {
        #region Method Results

        /// <summary>
        /// Result returned by a call to method ProviderName
        /// </summary>
        public string ProviderName_Result { get; set; }

        /// <summary>
        /// Result returned by a call to method ProviderId
        /// </summary>
        public Guid ProviderId_Result { get; set; }

        /// <summary>
        /// Result returned by a call to method GetAvailableForums
        /// </summary>
        public IList<Forum> GetAvailableForums_Result { get; set; }

        /// <summary>
        /// Result returned by a call to method GetUpdatedThreads
        /// </summary>
        public IList<Thread> GetUpdatedThreads_Result { get; set; }

        /// <summary>
        /// Result returned by a call to method GetSupportedBrands
        /// </summary>
        public IList<String> GetSupportedBrands_Result { get; set; }

        /// <summary>
        /// Result returned by a call to method GetForum
        /// </summary>
        public Forum GetForum_Result { get; set; }

        /// <summary>
        /// Result returned by a call to method GetUpdatedPosts
        /// </summary>
        public IList<Post> GetUpdatedPosts_Result { get; set; }

        /// <summary>
        /// Result returned by a call to method GetAllPosts
        /// </summary>
        public IList<Post> GetAllPosts_Result { get; set; }

        /// <summary>
        /// Result returned by a call to method GetSupportedLocales
        /// </summary>
        public IList<KeyValuePair<int, string>> GetSupportedLocales_Result { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether [fail at creating question thread].
        /// </summary>
        /// <value>
        /// 	<c>true</c> if [fail at creating question thread]; otherwise, <c>false</c>.
        /// </value>
        public bool FailAtCreatingQuestionThread { get; set; }
        /// <summary>
        /// Gets or sets a value indicating whether [fail at creating comment thread].
        /// </summary>
        /// <value>
        /// 	<c>true</c> if [fail at creating comment thread]; otherwise, <c>false</c>.
        /// </value>
        public bool FailAtCreatingCommentThread { get; set; }
        /// <summary>
        /// Gets or sets a value indicating whether [fail at creating reply].
        /// </summary>
        /// <value>
        /// 	<c>true</c> if [fail at creating reply]; otherwise, <c>false</c>.
        /// </value>
        public bool FailAtCreatingReply { get; set; }
        /// <summary>
        /// Gets or sets a value indicating whether [fail at marking as answer].
        /// </summary>
        /// <value>
        /// 	<c>true</c> if [fail at marking as answer]; otherwise, <c>false</c>.
        /// </value>
        public bool FailAtMarkingAsAnswer { get; set; }
        /// <summary>
        /// Gets or sets a value indicating whether [fail at unmarking as answer].
        /// </summary>
        /// <value>
        /// 	<c>true</c> if [fail at unmarking as answer]; otherwise, <c>false</c>.
        /// </value>
        public bool FailAtUnmarkingAsAnswer { get; set; }
        public DetailedUser GetCurrentUser_Result;

        #endregion

        #region IForumServiceProvider Members

        /// <summary>
        /// The name of this sync provider
        /// </summary>
        public string ProviderName
        {
            get { return ProviderName_Result; }
        }

        /// <summary>
        /// The unique provider Id for this sync service
        /// </summary>
        public Guid ProviderId
        {
            get { return ProviderId_Result; }
        }

        /// <summary>
        /// Gets the current user.
        /// </summary>
        /// <returns></returns>
        public DetailedUser CurrentUser
        {
            get
            {
                return GetCurrentUser_Result;
            }
        }

        /// <summary>
        /// Gets a list of all the forums 
        /// </summary>
        /// <param name="brand"></param>
        /// <param name="locale"></param>
        /// <returns>List of Forums for the given brand and locale</returns>
        public IList<Forum> GetAvailableForums(string brand, int locale)
        {
            return GetAvailableForums_Result;
        }

        /// <summary>
        /// Get a collection of all the supported brands
        /// </summary>
        /// <returns>collection of brands</returns>
        public IList<string> SupportedBrands
        {
            get
            {
                return GetSupportedBrands_Result;
            }
        }

        /// <summary>
        /// Get a collection of all the supported locales
        /// </summary>
        /// <returns>collection of locales</returns>
        public IList<KeyValuePair<int, string>> SupportedLocales
        {
            get
            {
                return GetSupportedLocales_Result;
            }
        }

        /// <summary>
        /// Get a collection of forum objects which have been deleted
        /// </summary>
        /// <param name="fromDate">Deletions after this date</param>
        /// <param name="toDate">Deletions before this date</param>
        /// <returns>The collection</returns>
        public IList<Forum> GetDeletedForums(DateTime fromDate, DateTime toDate)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Get the forum object given a forum id
        /// </summary>
        /// <param name="forumID">The id of the forum</param>
        /// <returns>A forum object</returns>
        public Forum GetForum(Guid forumId)
        {
            return GetForum_Result;
        }

        /// <summary>
        /// Gets every thread of a forum
        /// </summary>
        /// <param name="forumID">The parent forum</param>
        /// <returns>The collection of threads</returns>
        public IList<Thread> GetAllThreads(Guid forumId)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Get all the threads of a forum which have been update between the fromData and toDate
        /// </summary>
        /// <param name="forumID">ID of the parent forum</param>
        /// <param name="fromDate">Updated after this date</param>
        /// <param name="toDate">Updated before this date</param>
        /// <returns>Collection of updated threads</returns>
        public IList<Thread> GetUpdatedThreads(Guid forumId, DateTime fromDate, DateTime toDate)
        {
            return GetUpdatedThreads_Result;
        }

        /// <summary>
        /// Get a collection of thread objects which have been deleted
        /// </summary>
        /// <param name="forumID">ID of the parent forum</param>
        /// <param name="fromDate">Deletions after this date</param>
        /// <param name="toDate">Deletions before this date</param>
        /// <returns>The collection</returns>
        public IList<Thread> GetDeletedThreads(Guid forumId, DateTime fromDate, DateTime toDate)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Get the thread object given a forum id
        /// </summary>
        /// <param name="forumId">The forum id.</param>
        /// <param name="threadId">The thread id.</param>
        /// <returns>A thread object</returns>
        public Thread GetThread(Guid forumId, Guid threadId)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Gets every post of a thread
        /// </summary>
        /// <param name="forumId">The forum id.</param>
        /// <param name="threadId">The thread id.</param>
        /// <returns>The collection of posts</returns>
        public IList<Post> GetAllPosts(Guid forumId, Guid threadId)
        {
            return GetAllPosts_Result;
        }

        /// <summary>
        /// Get all the posts of a forum which have been update between the fromData and toDate
        /// </summary>
        /// <param name="forumId">The forum id.</param>
        /// <param name="threadId">The thread id.</param>
        /// <param name="fromDate">Updated after this date</param>
        /// <param name="toDate">Updated before this date</param>
        /// <returns>Collection of updated posts</returns>
        public IList<Post> GetUpdatedPosts(Guid forumId, Guid threadId, DateTime fromDate, DateTime toDate)
        {
            return GetUpdatedPosts_Result;
        }

        /// <summary>
        /// Get a collection of post objects which have been deleted
        /// </summary>
        /// <param name="forumId">The forum id.</param>
        /// <param name="threadId">The thread id.</param>
        /// <param name="fromDate">Deletions after this date</param>
        /// <param name="toDate">Deletions before this date</param>
        /// <returns>The collection</returns>
        public IList<Post> GetDeletedPosts(Guid forumId, Guid threadId, DateTime fromDate, DateTime toDate)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Get the post object given a forum id
        /// </summary>
        /// <param name="forumId">The forum id.</param>
        /// <param name="postId">The post id.</param>
        /// <returns>A post object</returns>
        public Post GetPost(Guid forumId, Guid postId)
        {
            throw new NotImplementedException();
        }



        /// <summary>
        /// Pings the web service
        /// </summary>
        /// <returns> Logged in users id if succesfull</returns>
        public string Ping()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// The Uri that this service provider is connected to
        /// </summary>
        /// <value></value>
        public Uri Uri
        {
            get { throw new NotImplementedException(); }
        }


        /// <summary>
        /// Authenticates the current user for this service
        /// </summary>
        /// <param name="information"></param>
        /// <returns>True if successfully authenticated</returns>
        public bool TryAuthenticate(ref AuthenticationInformation information)
        {
            throw new NotImplementedException();
        }


        /// <summary>
        /// The batch size for data retrieval
        /// </summary>
        /// <value></value>
        public int BatchSize
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        /// <summary>
        /// Gets or sets the authentication ticket.
        /// </summary>
        /// <value>The authentication ticket.</value>
        public string AuthenticationTicket
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        public void CreateQuestionThread(Guid forumId, string title, string body)
        {
            if (FailAtCreatingQuestionThread)
            {
                throw new Exception();
            }
        }

        public void CreateCommentThread(Guid forumId, string title, string body)
        {
            if (FailAtCreatingCommentThread)
            {
                throw new Exception();
            }
        }

        public void CreateReply(Guid threadId, Guid postId, string body)
        {
            if (FailAtCreatingReply)
            {
                throw new Exception();
            }
        }

        public void MarkPostAsAnswer(Guid postId)
        {
            if (FailAtMarkingAsAnswer)
            {
                throw new Exception();
            }
        }

        public void UnmarkPostAsAnswer(Guid postId)
        {
            if (FailAtUnmarkingAsAnswer)
            {
                throw new Exception();
            }
        }

        #endregion
    }
}
